<?php


namespace app\admin\controller;


use app\admin\validate\FilesValidate;
use app\BaseController;
use app\Code;
use app\lib\exception\ServiceException;
use app\service\AuthService;
use app\service\FilesService;
use think\App;
use think\exception\ValidateException;

class FilesController extends BaseController
{
    private $service;

    public function __construct(App $app)
    {
        $this->service = new FilesService();
        parent::__construct($app);
    }

    public function upload(){
        $file = $this->request->file('file');

        validate(FilesValidate::class)
            ->scene('file')
            ->check(['image' => $file]);

        return $this->returnJson($this->service->uploadFile($file));
    }

}